package com.sihan.framework.etm.service.impl;

import java.util.List;

import com.sihan.framework.etm.common.CacheOperatorInfo;
import com.sihan.framework.etm.common.util.EtmWebUtil;
import com.sihan.framework.etm.mapper.OrgMapper;
import com.sihan.framework.etm.vo.statistics.CurrentStateResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.framework.mybatis.service.impl.BaseServiceImpl;
import com.sihan.framework.etm.dto.CommonQueryDTO;
import com.sihan.framework.etm.entity.baseData.UseLocalModel;
import com.sihan.framework.etm.mapper.CommonMapper;
import com.sihan.framework.etm.service.CommonService;
import com.sihan.framework.etm.vo.CommonQueryResultVO;

@Service
public class CommonServiceImpl extends BaseServiceImpl<CommonQueryResultVO, String> implements CommonService {

	@Autowired
	private CommonMapper commonMapper;
	@Autowired
	private OrgMapper orgMapper;



	@Override
	public List<CommonQueryResultVO> selectPageForPull(CommonQueryDTO dto) {
		List<CommonQueryResultVO> result = null;
		switch(dto.getQueryType()) {
			case 1 : 
				result = commonMapper.selectDeviceCodeForPull(dto);
				break;
			case 2 : 
				result = commonMapper.selectToolCodeForPull(dto);
				break;
			case 3 : 
				result = commonMapper.selectUserNameForPull(dto);
				break;
			case 4 : 
				result = commonMapper.selectUserCodeForPull(dto);
				break;
			case 5 : 
				result = commonMapper.selectRoleForPull(dto);
				break;
			case 6 : 
				result = commonMapper.selectUserAndPhoneForPull(dto);
				break;
			case 7 : 
				result = commonMapper.selectManufatorForPull(dto);
				break;
			case 8 : 
				result = commonMapper.selectPositionDeviceForPull(dto);
				break;
			case 9 : 
				result = commonMapper.selectToolTypeModelForPull(dto);
				break;
			case 10 : 
				result = commonMapper.selectToolPurchaseForPull(dto);
				break;
			case 11 : 
				result = commonMapper.selectTaskNameForPull(dto);
				break;
			case 12 :
				result = commonMapper.selectToolClassifyForPull(dto);
				break;
			case 13 :
				result = commonMapper.selectNeedBorrowTaskNameForPull(dto);
				break;
			case 14 :
				result = commonMapper.selectToolClassForPull(dto);
				break;
			case 15 :
				result = commonMapper.selectToolStandardForPull(dto);
				break;
			case 16 :
				result = commonMapper.selectToolInspectMechanismForPull(dto);
				break;
		}
		return result;
	}
	@Override
	public List<CurrentStateResultVO> currentStateResultVOS(CommonQueryDTO dto) {
		List<CurrentStateResultVO> result = null;
		if (dto.getQueryType() == 17) {
			result = commonMapper.selectCurrentState(dto);
		}
		return result;
	}

	@Override
	public UseLocalModel queryUseLocal() {
		return commonMapper.queryUseLocal();
	}

	@Override
	public List<CommonQueryResultVO> unboundDevice(){

		String orgIds = (String) CacheOperatorInfo.getMapValue(EtmWebUtil.userId(), null);
		List<CommonQueryResultVO> commonQueryResultVOS = commonMapper.selectDeviceBindingTicket(orgIds.split(","));
		return commonQueryResultVOS;
	}


}
